<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>UI测试控制台</title>
    <script src="{{url_for('static', filename='js/jquery.min.js')}}"></script>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
          integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">

    <!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css"
          integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"
            integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd"
            crossorigin="anonymous"></script>
    <link rel="stylesheet" href="{{url_for('static', filename='css/css.css')}}">
</head>
<body>
<nav class="nav">
    <!--    <button>一键安装</button>-->
    <a target="_blank" class="btn btn-success download">一键安装</a>
    <a target="_blank" class="btn btn-danger del_btn">一键删除</a>
    <a target="_blank" class="btn btn-primary weditor">weditor</a>
    <a target="_blank" class="btn btn-primary open_btn">一键启动</a>
    <!--    <button>一键删除</button>-->
    <button class="login_btn">测试登录</button>
    <button>接口测试</button>
    <button>首页测试</button>
</nav>

<div id="container" class="container">
    <div class="row">
        <div class="col-md-4">
            <form class="navbar-form" id="ip_form">
                <div class="form-group">
                    <input type="text" name="k" id="k" class="form-control" placeholder="设备串行号" value="">
                </div>
                <button type="submit" class="btn btn-default ip_submit">连接设备</button>
            </form>
        </div>
        <div class="col-md-4">
            <form class="navbar-form" id="screen_form">
                <div class="form-group">
                    <input type="text" name="ip" id="screen_ip" class="form-control" placeholder="ip地址" value="">
                </div>
                <button type="submit" class="btn btn-default screen_submit">设备投屏</button>
            </form>
        </div>
        <div class="col-md-4">
            <form class="navbar-form" id="disconnect_form">
                <div class="form-group">
                    <input type="text" name="series_ip" id="series_ip" class="form-control" placeholder="ip地址" value="">
                </div>
                <button type="submit" class="btn btn-default series_submit">断开连接</button>
            </form>
        </div>
    </div>
    <h3>当前连接的设备：</h3>
    <pre class="pre_devices_list">{{info}}</pre>

</div>
</body>
<script>
    $(function () {
        $(".download").click(function (e) {
            e.preventDefault()
            $.ajax({
                url: '/install',
                success: e => {
                    console.log(e)
                }
            })
        })
        $(".del_btn").click(function (e) {
            e.preventDefault()
            $.ajax({
                url: '/uninstall',
                success: e => {
                    console.log(e)
                }
            })
        })
        $(".login_btn").click(function (e) {
            e.preventDefault()
            $.ajax({
                url: '/ui.login',
                success: e => {
                    console.log(e)
                }
            })
        })
        $(".open_btn").click(function (e) {
            e.preventDefault()
            $.ajax({
                url: '/start',
                success: e => {
                    console.log(e)
                }
            })
        })
        $(".weditor").click(function (e) {
            e.preventDefault()
            $.ajax({
                url: '/weditor',
                success: e => {
                    console.log(e)
                }
            })
        })
        $(".ip_submit").click(function (e) {
            e.preventDefault()
            let serial = $('#k').val()
            $.ajax({
                url: `/connect?k=${serial}`,
                success: e => {
                    location.reload()
                }
            })
        })
        $(".screen_submit").click(function (e) {
            e.preventDefault()
            let serial = $('#screen_ip').val()
            $.ajax({
                url: `/screen?ip=${serial}`,
                success: e => {
                    console.log(e)
                }
            })
        })
        $(".series_submit").click(function (e) {
            e.preventDefault()
            const ip = $('#series_ip').val()
            $.ajax({
                url: `/disconnect?ip=${ip}`,
                success: e => {
                    if (e.code !== 200) {
                        console.log(e)
                    } else {
                        location.reload()
                    }
                }
            })
        })
    })
</script>
</html>